import { createRouter, createWebHistory } from 'vue-router'

//导入组件
import login from '@/views/longin.vue'
import ScriptCategory from '@/views/ScriptCategory.vue'
import ScriptDetail from '@/views/ScriptDetail.vue'
import ScriptManagement from '@/views/admin/ScriptManagement.vue'
import AdminDashboard from '@/views/admin/AdminDashboard.vue'
import CategoryManagement from '@/views/admin/CategoryManagement.vue'
import TagManagement from '@/views/admin/TagManagement.vue'

//定义路由关系
const routes = [
    { path: '/login', component: login },
    { path: '/', name: 'ScriptCategory', component: ScriptCategory, meta: { keepAlive: true } },
    { path: '/script/:id', name: 'ScriptDetail', component: ScriptDetail, props: true },
    { path: '/admin', name: 'AdminDashboard', component: AdminDashboard },
    { path: '/admin/scripts', name: 'ScriptManagement', component: ScriptManagement },
    { path: '/admin/categories', name: 'CategoryManagement', component: CategoryManagement },
    { path: '/admin/tags', name: 'TagManagement', component: TagManagement }
] 

//创建路由器
const router = createRouter({
    history: createWebHistory(),
    routes: routes
})

export default router
